package cn.dy.sbo.web;

import com.opensymphony.xwork2.ActionSupport;
import java.util.Locale;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.util.WebUtils;
import org.springside.modules.utils.web.struts2.Struts2Utils;

public class SetlocalAction extends ActionSupport {
	private static final long serialVersionUID = 1L;
	private String local;

	public String execute() throws Exception {
		if (local == null) {
			Struts2Utils.renderJson("{error}");
			return null;
		} else {
			WebUtils.setSessionAttribute(Struts2Utils.getRequest(),
					SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME,
					new Locale(local));
			Struts2Utils.renderJson("{success}");
			return null;
		}
	}

	public String getLocal() {
		return local;
	}

	public void setLocal(String local) {
		this.local = local;
	}
}
